import requests
import json


headers = {
    "accept": "application/json, text/plain, */*",
    "accept-language": "zh-CN,zh;q=0.9",
    "cache-control": "no-cache",
    "content-type": "application/json;charset=UTF-8",
    "origin": "https://www.xiaohongshu.com",
    "pragma": "no-cache",
    "priority": "u=1, i",
    "referer": "https://www.xiaohongshu.com/",
    "sec-ch-ua": "\"Not)A;Brand\";v=\"8\", \"Chromium\";v=\"138\", \"Microsoft Edge\";v=\"138\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-site",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0",
    "x-b3-traceid": "0179b3385cce166d",
    "x-mns": "unload",
    "x-s": "XYW_eyJzaWduU3ZuIjoiNTYiLCJzaWduVHlwZSI6IngyIiwiYXBwSWQiOiJ4aHMtcGMtd2ViIiwic2lnblZlcnNpb24iOiIxIiwicGF5bG9hZCI6IjUwNjIzMzNhMjg2NWUyNTA4ODBlNmQ1Yzk5NmViNTJhYWZkYzYwODVlZDNkOGEwOTdkYzkxMTU3MWYxYWE0ZGQyYmExNTFjZjkyMGRkYWIxOWRkZTk5ZTcxZGUxM2EyNmQ5MTczYmNkMGFjMjU0OThjNmY3NTViZDAwMmRhODFhNzY2ZWFlMTc5ZTUxMjE4YzIwZjkzMDMzZTdiM2EwYzBkMGUzZTE5ZTRkZWJjMmY0OWJlNzEzM2QzYmJmMzhkMzZmYjBmMDA2NmY5NTQxNDZlYzFmZTdmYmM5MGIxMmJkMzA2MmY3MDI1YjNjODY1MzBjOTkxNzgyNmFkZTQxZTVjODJlYzk2ZDFhNDQzNmZjM2E5YmNmZmEzYjE0MzBlN2NjYzM4YmY5NDhhN2M1ZjgyY2I2MTVhZTA5NTdkMDA3NGQzNzMwMGZjMzU4ZGViMWEwYzNhZWE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bn4ebQyLEAPgb7+LSiN7+8qgz/z7b72nMl4FzQ4DS3aL+I4rRx/pPFJ04AnpmFpDSkLdkQye+ApMm7a94Q2dQ0JDEAnppT4LSkyrlS4g4la7p7LFSk87P9qgqULgmD8nSIad+LqDMPanY9qA8s/7PlqgzAcS87/DS9afpfpd4QanTd8nTAqDlQPA4S8BG68p4n4bQQPA4S+dpF+74xpjRQygmQa/P68/+y+7+ncnzAPbkd8/bl4BpQzgbaa/+8c7mc4AYQyp+QanVMqA+jaL+wJ0+SPop7aFSkzFR0qg4yLrc68p4r+g+xn0FRHjIj2eDjw0rM+eHF+eH9weDVHdWlPsHCPsIj2erlH0ijJfRUJnbVHdF=",
    "x-t": "1751536091913",
    "x-xray-traceid": "cbe7d7e1822a1b9ba6831db347d36574"
}
cookies = {
    "abRequestId": "a43ad666-a02e-58ca-9118-2e1060b1acdc",
    "webBuild": "4.70.2",
    "xsecappid": "xhs-pc-web",
    "loadts": "1751535929223",
    "a1": "197cfad4787s2rvodll9lz3rs9y4gbltcy9wx28xi50000828195",
    "webId": "34e7f10a591d745df3ecbf326332c90c",
    "acw_tc": "0a5088c817515359316204999e079d097fdb302f2b8dcb8f6c51e6d1ef2942",
    "websectiga": "7750c37de43b7be9de8ed9ff8ea0e576519e8cd2157322eb972ecb429a7735d4",
    "sec_poison_id": "9cda99a7-cd9a-453a-952a-f4e48ee3d369",
    "gid": "yjWSi0fKKKSyyjWSi0f4WvJYYWMJFhlf11j1jC3uqFMjvE284kD19C888YJYyj28if22yjfY",
    "web_session": "0400698dcff4bb17b14af219533a4b27d51754",
    "unread": "{%22ub%22:%226865301e00000000100105bc%22%2C%22ue%22:%22685d10d6000000001c031e30%22%2C%22uc%22:12}"
}
url = "https://edith.xiaohongshu.com/api/sns/web/v1/homefeed"
data = {
    "cursor_score": "",
    "num": 18,
    "refresh_type": 1,
    "note_index": 17,
    "unread_begin_note_id": "",
    "unread_end_note_id": "",
    "unread_note_count": 0,
    "category": "homefeed_recommend",
    "search_key": "",
    "need_num": 8,
    "image_formats": [
        "jpg",
        "webp",
        "avif"
    ],
    "need_filter_image": False
}
data = json.dumps(data, separators=(',', ':'))
response = requests.post(url, headers=headers, cookies=cookies, data=data)

print(response.text)
print(response)